<%@ page language="Java" import="java.util.*,descriptor.*,cv.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<%
	OfferListDescriptor persoOfferList = (OfferListDescriptor)request.getAttribute("persoOfferList");
	String error1 = (String)request.getAttribute("error1");
%>

<%	
	String notif = "";
	if(error1 != null)
	{
		notif = "<p style=\"color:red; font-size: 10px;\">" + error1 + "<p>";
	}
%>

<html>
	<jsp:include page="StudentHeader.jsp" >
		<jsp:param name="pageTitle" value="Work Placement Management System - Student" />
	</jsp:include>
	<body OnLoad="showmenu(document.getElementById('smenu6'));">
		<jsp:include page="StudentPageHeader.jsp"></jsp:include>
		<div id="container">
			<jsp:include page="StudentMenu.jsp" ></jsp:include>
			<div id="content">
				<h3 class="posttitle">Student - Personnal & Applied Offers</h3>
				<div class="entry">
					<%= notif %>
					<%
							int sizeList = persoOfferList.sizeOfferList(); 
							if(sizeList>0)
							{
					%>
					<table rules="all">
						<thead>
							<tr><th>Offer</th><th>Company</th><th>Expiry Date</th><th>Description</th><th>Action</th></tr>
						</thead>
					<%
								for(int i=0; i<sizeList; i++)
								{	
									int id = persoOfferList.getOfferList().get(i).getId();
									String offer = persoOfferList.getOfferList().get(i).getName();
									String company = persoOfferList.getOfferList().get(i).getCompany();
									String expiry = persoOfferList.getOfferList().get(i).getDateOfEnd();
									String description = persoOfferList.getOfferList().get(i).getDescription();
									String interview = persoOfferList.getOfferList().get(i).getDateOfInterview() + " at " + persoOfferList.getOfferList().get(i).getHourOfInterview() +":"+ persoOfferList.getOfferList().get(i).getMinOfInterview() +" / Address: "+persoOfferList.getOfferList().get(i).getAddressOfInterview();
									int status = persoOfferList.getOfferList().get(i).getStatus();
									int type = persoOfferList.getOfferList().get(i).getType();
									String style = "";
									if(status == 8)
										style = "style=\"background-color: #66ee00;\"";
									if(status == 7)
										style = "style=\"background-color: #ff3333; color= white;\"";
										
					%>
						<tr <%= style %>>
							<td><%= offer %></td>
							<td><%= company %></td>
							<td><%= expiry %></td>
							<td><%= description %></td>
					<%
									if(status == 4 && type == 0)
									{
					%>
							<td>
								<form name="accept<%= i %>" method="post">
									<input type="hidden" name="action" value="acceptOffer">
									<input type="hidden" name="offerID" value="<%= id %>">     
								</form> 
								<a href="javascript:document.accept<%= i %>.submit();" title="Accept Offer: <%=  offer %>">Accept</a>
								<form name="reject<%= i %>" method="post">
									<input type="hidden" name="action" value="rejectOffer">
									<input type="hidden" name="offerID" value="<%= id %>">     
								</form> 
								<a href="javascript:document.accept<%= i %>.submit();" title="Reject Offer: <%=  offer %>">Reject</a>
							</td>
				<%
									}
									else
									{
										if(status == 4  || status == 2)
										{
									
				%>
							<td>Wait for interview</td>
				<%						
										}
										else
										{
											if(status == 5)
											{
				%>
							<td><%= interview %></td>
				<%
											}
										}
										if(status == 6)
										{
				%>
							<td>
								<form name="accept<%= i %>" method="post">
									<input type="hidden" name="action" value="acceptOffer2">
									<input type="hidden" name="offerID" value="<%= id %>">     
								</form> 
								<a href="javascript:document.accept<%= i %>.submit();" title="Accept this workplacement: <%=  offer %>">Accept</a>
								<form name="reject<%= i %>" method="post">
									<input type="hidden" name="action" value="rejectOffer2">
									<input type="hidden" name="offerID" value="<%= id %>">  
									<input id="offer<%= i %>" type="hidden" value="<%= offer %>">   
								</form> 
								<a href="javascript:openDeleteWindow(document.getElementById('offer<%= i %>'),document.reject<%= i %>);" title="Reject & Delete this workplacement <%=  offer %>">Reject</a>
							</td>
				<% 							
										}
										else
										{
											if(status == 8)
											{
				%>
												<td>WORPLACEMENT ACCEPTED</td>
				<%
											}
											if(status == 7)
											{
				%>
												<td>WORPLACEMENT REJECTED BY THE COMPANY</td>
				<%
											}
										}
									}
				%>
						</tr>
				<%
							}
						}
				%>
					</table>
				</div>
	    	</div>
			<jsp:include page="StudentPageFooter.jsp"></jsp:include>
		</div>
	</body>
</html>